package com.example.gsnd21study.web;

import com.example.gsnd21study.entity.DRO.UserAndRole;
import com.example.gsnd21study.entity.User;
import com.example.gsnd21study.service.UserService;
import com.example.gsnd21study.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final  UserService userService;


    // 实现 查询指定用户的信息，并且携带角色信息

    @GetMapping("/andRole/{userId}")
    public Result<UserAndRole> find(@PathVariable Long userId) {
        UserAndRole userAndRole = userService.find(userId);
        return Result.success(userAndRole);
    }

    @GetMapping("/limit")
    public Result<List<User>> findAll(@RequestParam Integer pageNo , @RequestParam Integer pageSize) {
        List<User> users = userService.limitFind(pageNo , pageSize);
        return Result.success(users);
    }

}
